package com.cwt_taxi_xa.receiver;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;

import com.cwt_taxi_xa.util.ToastUtils;

public class ApkInstallReceiver extends BroadcastReceiver {

	@Override
	public void onReceive(Context context, Intent intent) {
		try {
			if (intent.getAction().equals("android.intent.action.PACKAGE_ADDED" )) {
				//String packageName = intent.getDataString().substring(8);  
				//NetworkHandler.showToast("安装:" +packageName + "包名的程序");
			}

			//接收卸载广播
			if (intent.getAction().equals("android.intent.action.PACKAGE_REMOVED" )) {
				String packageName = intent.getDataString().substring(8);
				if(packageName.equals("com.cwt_taxi_xa")){
					//				new ProcessManager(context).kill(NaviConstants.AUTONAVI_PACKEG);
					ToastUtils.showToast("应用重启...");
					Intent newIntent =  new Intent();
					newIntent.setClassName(packageName,packageName+ ".ActivityWaitQD" );
					newIntent.setAction("android.intent.action.MAIN");
					newIntent.addCategory("android.intent.category.LAUNCHER" );
					newIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
					context.startActivity(newIntent);
				}
			}
		} catch (Exception e) {
			// TODO Auto-generated catch block
			System.out.println("卸载");
		}
	}

}  
